package com.yurun.accountservice.tcc;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

import javax.annotation.Resource;

/**
 * 使用TCC模式必须定义这个接口
 * 1.mycommit时无异常时执行的操作
 * 2.rollBack是有异常回滚的操作
 *
 * @author Xi Gao
 * @date 2020/9/12 16:18
 */
@LocalTCC
public interface AccountActionService {

    @TwoPhaseBusinessAction(name = "reduceMoney", commitMethod = "mycommit", rollbackMethod = "myrollBack")
    boolean reducerAccountMoney(BusinessActionContext context, @BusinessActionContextParameter(paramName = "userId") String userId, @BusinessActionContextParameter(paramName = "money") Integer money);

    boolean mycommit(BusinessActionContext context);

    boolean myrollBack(BusinessActionContext context);

}